<script setup>
import { onMounted } from 'vue';
import { useRouter, useRoute } from 'vue-router';

const router = useRouter();
const route = useRoute();

onMounted(() => {
  const isAuthenticated = localStorage.getItem('token');
  if (!isAuthenticated && route.path !== '/login') {
    router.push('/login'); // 未登录时跳转到登录页
  }
});
</script>

<template>
  <div id="app">
    <router-view/>
  </div>
</template>

<style scoped>
</style>